home *** CD-ROM | disk | FTP | other *** search
- /* © Copyright 1989,90,91 The NetWork Project, StatLab Heidelberg.
- © Copyright 1989,90,91 Joachim Lindenberg, Karlsruhe,
- Günther Sawitzki, Heidelberg. All rights reserved. */
-
- /* NetWork.h */
-
- /*
- This header file is yet incomplete, but it interfaces to the most
- important functions that are available in the NetWork library.
-
- WARNING : This file is translated by hand, it may be in error or
- simply out of date. Consult the pascal version if in doubt.
-
- See SampleTool.c & UDPTransport.c for examples on using NetWork with C.
- */
-
- /*
- This library does not support code without an A5 world. If you want to use
- NetWork from other code (non application, non tool), you´ll have to use
- control calls to the driver directly. Contact us if you need help with that.
-
- The library uses a call to NetWork Processor to find out whether this process
- is already known to NetWork. If it is, it is assumed to be launched by NetWork
- by means of a message or idle time launch, and the type and signature are confirmed.
- If it is not known, the process is registered using the default type and the
- application´s signature. The default type is pMaster unless you set pDefault to
- something different. It is allowed to use pSlave or pLocal even if not launched
- automatically, and the process will be subject to the rules of slave/local
- processes in that case.
- */
-
- #ifndef __NetWork__
- #define __NetWork__
-
- #include <Types.h>
- #include <OSUtils.h>
-
- /* ============================================================= */
-
- /* global declarations - general use */
-
- /* general error messages - many of them are never returned to user processes.
- Also other operating system error codes may bubble up. */
-
- /* some of these codes should be reconsidered, also some of them could be more specific */
-
- #define eQueEmpty -31000 /* no more messages avail - out of memory */
- #define ePrio2Big -31001 /* priority information too big */
- #define eNoSuchMsg -31002 /* invalid or NIL message reference, no message avail (GET) */
- #define eNotLaunched -31003 /* destination process does not exist - NOT USED */
- #define eAbortMsg -31004 /* message transfer aborted */
- #define eProcTableFull -31005 /* process table full (Init/Exit) */
- #define eNoSuchProcess -31006 /* specified process unknown */
- #define eNoMoreDynamics -31007 /* maximum number of dynamic ids exceeded */
- #define eLaunchFailed -31008 /* launch failed - NOT USED */
- #define eInvalid -31009 /* local message transfer aborted */
- #define eSizeLimit -31010 /* message larger than supported by transport - AppleTalk broadcast - eMsg2Big */
- #define eVersion -31011 /* version of library/driver/transport/system */
- #define eProtType -31012 /* no transport, invalid network address - Dispatcher */
- #define eLoopback -31013 /* discard of broadcasted message - NEVER returned to user */
- #define eTransportDown -31014 /* transport system not available - AppleTalk */
- #define eCmdSequence -31015 /* cmd sequencing error - bug of NetWork Processor or Dispatcher */
- #define eProtIndex -31016 /* protocol index out of range - GetTransport */
- #define eProcessExists -31017 /* creator registered for a DIFFERENT process - process mgmt */
- #define eProcessIndex -31018 /* invalid process index - GetIndexedProcess */
- #define eProcessType -31019 /* process type illegal or does not match launch - process mgmt */
- #define eRestartListen -31020 /* a listener handled a request for more data,
- and requires a restart therefore - AppleTalk - NEVER returned to user */
- #define eMsgTimeout -31021 /* maximum message lifetime exceeded - AppleTalk */
- #define eNoSignature -31022 /* couldn´t obtain signature of application file - Library */
- #define eMsgLockFailed -31023 /* couldn´t lock message - NOT USED */
- #define eSigTableFull -31024 /* signature table full */
- #define eSigRegistered -31025 /* signature already registered */
- #define eSigNotRegistered -31026 /* signature not registered */
- #define eProcMgmtError -31027 /* internal error */
- #define eSourceSig -31028 /* source signature wrong in Send/Post */
- #define eSourceAddr -31029 /* source address wrong in Send/Post */
-
- /* capas defined */
-
- #define cMustExist 0x080000000; /* process must exist -- don´t launch */
-
- /* idle monitor states - see NetWork TN 12 Idle Monitor States */
-
- #define imBusy 0
- #define imIdle 1
- #define imActive 2
- #define imLoaded 3
-
- /* process types - see NetWork Communications */
-
- #define pUnknown 0;
- #define pSlave 1;
- #define pLocal 2;
- #define pMaster 3;
-
- /* transport system constants */
-
- /* major command codes */
-
- #define tGeneral 0x00
- #define tListen 0x10
- #define tGet 0x20
- #define tAccept 0x30
- #define tSend 0x40
- #define tPost 0x40
-
- /* minor command codes */
-
- #define tStart 0x00
- #define tTimeout 0x0c
- #define tTimeout1 0x0d
- #define tAbort 0x0e
- #define tAbort1 0x0f
-
- /* misc command codes */
-
- #define tInit 0x00
- #define tTickle 0x01
- #define tDeregister 0x02
- #define tRegister 0x03
- #define tShutdown 0x0f
-
- /* useful values */
-
- #define tMajorMask 0x0f0
- #define tMinorMask 0x00f
-
- typedef struct MsgAddr MsgAddr;
- typedef struct MsgRec MsgRec, *MsgPtr;
- typedef struct TransportRecord TransportRecord, *TransportPtr;
-
- struct MsgAddr {
- long a, p;
- };
-
- /* except for MsgUserRefCon all of the components are READ ONLY */
-
- struct MsgRec {
- MsgPtr MsgLink;
- void * Msg2ndLink;
- short MsgResult;
- unsigned char MsgFlags, MsgCmd;
- long MsgTicks;
-
- long MsgUserRefCon;
- long MsgReserved1, MsgReserved2, MsgReserved3;
- TransportPtr MsgTrpPtr;
- long MsgTrpRefCon;
-
- /* message header information - all of this is transported to the destination */
-
- MsgAddr MsgSource,
- MsgDest,
- MsgReply;
- long MsgCapasVerb,
- MsgReference,
- MsgPrioSize,
- MsgCoreSize;
- Ptr MsgPrioPtr,
- MsgCorePtr;
- };
-
- /* transport system */
-
- struct TransportRecord {
- TransportPtr TransportLink; /* link to next transport in queue */
- void * TransportProc; /* pointer to definition proc - overlays magic */
- StringHandle TransportName; /* name of resource - overlays header vers & size */
- long TransportID; /* transport protocol (unique) signature */
- StringHandle TransportDomain; /* transport domain dependent string */
- long TransportAddr; /* local address of this transport system */
- long TransportBCAddr; /* this transports broadcast address */
- long TransportStart; /* first valid address on this transport */
- long TransportEnd; /* last valid address */
- short TransportMsgSize; /* size of MsgRecord for this transport system */
- short TransportListensRequested; /* see NetWork Transports for a discussion */
- short TransportListensStarted; /* of these three fields. */
- short TransportListensCompleted;
- long TransportReserved; /* reserved for future use */
- void * TransportVars; /* private vars, may be longint, ptr, or handle */
- MsgPtr * TransportMsgQHead; /* pointer to head of message queue */
- void * TransportAttnRtn; /* pointer to attn routine (supplied by NetWork) */
- };
-
-
- /* ============================================================= */
-
- /* conversion & logging
- Note: all strings are PASCAL string pointers */
-
- pascal void AddrToString (MsgAddr *, StringPtr);
- pascal void MsgToString (MsgPtr, StringPtr);
- pascal void LogString (StringPtr);
- pascal void LogStrTime (StringPtr);
- pascal void LogMsg (StringPtr, MsgPtr);
- pascal void CheckError (StringPtr, OSErr);
-
- /* ============================================================= */
-
- /* general utilities */
-
- pascal void ProgramBreak (StringPtr); /* drop into debugger if one is installed -- SADE ? (new calls) -- to go? */
- pascal Boolean Visible (void); /* display a user interface ? */
- pascal Boolean Spare (void); /* this returns the setting of the spare flag */
- pascal long TimeStamp (void); /* randomized timestamp, should be unique for each call -- (sample code) */
-
- /* ============================================================= */
-
- /* idle manager */
-
- pascal void PreventIdle (void); /* tell NetWork that we are doing useful stuff - to go ? */
- pascal short IdleMonitorState (void); /* state of idle monitor */
- pascal Boolean Idle (void); /* is the local system idle ? */
- pascal long IdleTicks (void); /* number of ticks we have been idle, < 0 if busy */
-
- /* ============================================================= */
-
- /* transport interface */
-
- pascal Boolean IsLocal (long); /* shouldn´t be used. to go ? */
- pascal OSErr GetTransport (TransportPtr *, short); /* to go ? */
- pascal QHdrPtr GetTransportQHdr (void);
- pascal OSErr InstallTransport (TransportPtr Trp);
- pascal OSErr RemoveTransport (TransportPtr Trp);
-
- /* ============================================================= */
-
- /* address management - to go ? */
-
- pascal Boolean EqAddr (MsgAddr *, MsgAddr *);
- pascal Boolean EqNode (MsgAddr *, MsgAddr *);
- pascal MsgAddr SetMsgAddr (long, long);
- pascal MsgAddr GetNetWorkAddr (void);
-
-
- /* ============================================================= */
-
- /* process management */
- /* most of the process management is done implicitly, these may
- be the things you are interested in. */
-
- extern long pFileSignature, pProcessSignature; /* valid after InitNetWork */
-
- pascal Boolean Master (void);
-
- pascal OSErr GetProcessType (long, short *);
- pascal OSErr SetProcessType (long, short);
- pascal OSErr GetIndProcess (long *, short);
- pascal OSErr LaunchLocalApplication (long *, short, long, StringPtr);
-
- /* ============================================================= */
-
- /* message management - remove GetMsg, rename GetThisMsg to GetMsg. */
-
- /* DumpMessages dumps all currently active messages - is this useful to applications ? */
-
- pascal void DumpMessages(void);
-
- /* AvailableMsg returns the number of available messages - to go */
-
- pascal int AvailableMsg(void);
-
- /* the following pascal void returns 0 if the Msg has been transferred completely
- < 0 if there was an error, > 0 indicates that the Msg is still transferred
- or waiting. */
-
- pascal OSErr MsgStatus (MsgPtr); /* to go ? */
-
- /* SignalMsg checks to see if a new or old message needs handling */
-
- pascal OSErr SignalMsg (MsgPtr *); /* useful for non app code */
-
- /* GetMsg checks to see if there is a new message available. */
-
- pascal OSErr GetIndexedMsg ( MsgPtr *,
- short, /*0=1*/
- Ptr,
- long);
-
- /* GetMsg gets a message that has been signaled */
-
- pascal OSErr GetMsg (MsgPtr, Ptr, long);
-
- /* FlushMsg discards all received messages not "Got" except those with DontFlushMask set */
-
- pascal OSErr FlushMsg (long);
-
- /* AcceptMsg will tell the transport system to receive the message and store
- it at the memory passed. */
-
- pascal OSErr AcceptMsg (MsgPtr, Ptr, long);
-
- /* PostMsg generates a new message that will be sent. It does not make a copy
- of the information that is referenced. */
-
- pascal OSErr PostMsg (MsgPtr *, TransportPtr, long, long, MsgAddr *, MsgAddr *, Ptr, long, Ptr, long);
-
- /* SendMsg uses the information in RefMsg to post a new message. All of the
- fields must be filled in. The message posted is returned in NewMsg. */
-
- pascal OSErr SendMsg (MsgPtr, MsgPtr *);
-
- /* ForwardMsg forwards a message to the same or another process on the same machine.
- Don´t call DestroyMsg for a message you forwarded except if you forward to yourself.
- ForwardMsg may be called after a GetMsg, but all buffer references will be removed */
-
- pascal OSErr ForwardMsg (MsgPtr, long);
-
- /* DestroyMsg gets rid of a message. This possibly kills a transfer */
-
- pascal OSErr DestroyMsg (MsgPtr);
-
- /* ============================================================= */
-
- /* initialization and termination. Call InitNetWork before use of anything
- within this unit. Call ExitNetWork as part of your cleanup sequence. */
-
- pascal OSErr InitNetWork (short);
- pascal OSErr ExitNetWork (void);
-
- #endif
-